package com.xdh.springcloud.data;

import com.xdh.springcloud.data.bean.TestUser;
import com.xdh.springcloud.data.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class SpringDataJpaApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringDataJpaApplication.class, args);
    }


    @Autowired
    private UserRepository userRepository;

    @PostConstruct
    public void test()  {

        // 创建10条记录
        userRepository.save(new TestUser("AAA", 10));
        userRepository.save(new TestUser("BBB", 20));
        userRepository.save(new TestUser("CCC", 30));
        userRepository.save(new TestUser("DDD", 40));
        userRepository.save(new TestUser("EEE", 50));
        userRepository.save(new TestUser("FFF", 60));
        userRepository.save(new TestUser("GGG", 70));
        userRepository.save(new TestUser("HHH", 80));
        userRepository.save(new TestUser("III", 90));
        userRepository.save(new TestUser("JJJ", 100));


    }
}
